/*
 * ui.c
 *
 *  Created on: 02/mag/2014
 *      Author: kappa
 */

#include "ui.h"
#include "commons.h"

int konsoleMsg(INTACTION interaction){
	char *input;
	int inputValue = 0;
	int waitanswer = 0;
	char* message = (char *)malloc(sizeof(char)*100);
	memset(message,0,100);
	switch(interaction){

	case GO_ON:
		message = strcat(message,MSG_GO_ON);
		waitanswer = 1;
		break;

	case CFG_NULL:
		message = strcat(message,MSG_CFG_NULL);
		waitanswer = 0;
		break;

	case LOG_NULL:
		message = strcat(message,MSG_LOG_NULL);
		waitanswer = 0;
		break;

	default: break;

	}
	fprintf(stdout,"\n%s\n",message);

	if(waitanswer){
		input =(char *) malloc(sizeof(char));
		fscanf(stdin,"%c", input);
		inputValue = evaluateSN(input);
		free(input);
		input = NULL;
		return inputValue;
	}
	else return 0;

}

int evaluateSN(char *c){
	if(*c == 'S' || *c == 's'){
		return 1;
	}
	else if(*c == 'N' || *c == 'n'){
		return -1;
	}
	else return 0;
}
